package com.shop.admin.controller;

import com.shop.Result.LdbzResult;
import com.shop.admin.service.AdminCategoryService;
import com.shop.pojo.LdbzCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/category/service")
public class AdminCategoryController {

    private static final Logger logger = LoggerFactory.getLogger(AdminCategoryController.class);

    @Autowired
    private AdminCategoryService adminCategoryService;

    @RequestMapping(value="/editCategory/{id}" , method = RequestMethod.GET)
    public LdbzResult editCategory(@PathVariable("id")long id , Model model) {
        return adminCategoryService.editCategory(id);
    }

    @RequestMapping(value="/getCategoryList" , method = RequestMethod.GET)
    public LdbzResult getCategoryList(LdbzCategory entity) {
        return adminCategoryService.getCategoryList(entity);
    }

    @RequestMapping(value="/getCategoryPage" , method = RequestMethod.GET)
    public LdbzResult getCategoryPage(LdbzCategory entity , int page , int limit) {
        return adminCategoryService.getCategoryPage(entity, page, limit);
    }

    @RequestMapping(value="/deleteByKey/{id}" , method = RequestMethod.GET)
    public LdbzResult deleteByKey(@PathVariable("id")String id) {
        return adminCategoryService.deleteByKey(id);
    }

    @RequestMapping(value="/insertByEntity" , method = RequestMethod.GET)
    public LdbzResult insertByEntity(LdbzCategory entity) {
        return adminCategoryService.insertByEntity(entity);
    }

    @RequestMapping(value="/updateByKey" , method = RequestMethod.GET)
    public LdbzResult updateByKey(LdbzCategory entity) {
        return adminCategoryService.updateByKey(entity);
    }

    @RequestMapping(value="/getCategoryTree/{fid}" , method = RequestMethod.GET)
    public LdbzResult getCategoryTree(@PathVariable("fid")long fid) {
        return adminCategoryService.getCategoryTree(fid);
    }

    @RequestMapping(value="/updateSort" , method = RequestMethod.GET)
    public LdbzResult updateSort(String ids) {
        return adminCategoryService.updateSort(ids);
    }
}
